import java.io.File;
import java.io.FileWriter;
import java.io.IOException;


public class PrintICS {
    private String version;
    private String classification;
    private String classification_end;
    private String comment;
    private String location;
    private String resources;
    private String dTSTART;
    private String dTEND;
    private String timeZone;
    private String recurring;


    public PrintICS(){
    version="";
    classification="";
    comment="";
    location="";
    resources="";
    dTSTART="";
    dTEND="";
    timeZone="";
    recurring="";
    }


    /************************************
    * Parameter:  "2.0";
    ************************************/
    public void setVersion(String vervalue){

    version = "VERSION:"+vervalue;

    }



    /******************************************************************
    * Parameter:  The property can be specified once in a "VEVENT",
    * "VTODO", or "VJOURNAL" calendar components.
    *****************************************************************/
    public void setClassification(String s){

    classification="BEGIN:"+s;
    classification_end="END:"+s;

    }


    /*********************************
    * Parameter:  text
    ********************************/
    public void setComment(String s){
    comment="COMMENT:"+s;
    }


    /**************************
    * Parameter:  text
    **************************/
    public void setLocation(String s){
    location="LOCATION:"+s;
    }

    /**************************
    * Parameter:  text
    **************************/
    public void setResources(String s){
    resources="RESOURCES:"+s;
    }

    /******************************
    * Parameter:  19960401T150000Z
    * or DTEND;VALUE=DATE:19980704
    ******************************/
    public void setDTSTART(String s){
    dTSTART = "DTSTART:"+s;
    }

    /******************************
    * Parameter:  19980118T073000Z
    ******************************/
    public void setDTEND(String s){
    dTEND ="DTEND:"+s;
    }


    /*********************************
    * Parameter:  America/New_York
    * Parameter:  America/Los_Angeles
    ********************************/
    public void setTimeZone(String s){
    timeZone="TZID:"+s;
    }

    /*************************************
    * Parameter: (RRULE:INTERVAL=?; FREQ=?
    *************************************/
    public void setRecurring(String s){
    recurring = s;
    }


    public void print(){
    try {
      System.out.println("Creating file event.ics.");
      FileWriter fw = new FileWriter(new File("event.ics"));
      fw.write("BEGIN:VCALENDAR" +
    	  "\r\n"+  version +
    	  "\r\n"+  timeZone +
    	  "\r\n"+  classification +
    	  "\r\n"+  comment +
    	  "\r\n"+  location +
    	  "\r\n"+  resources +
    	  "\r\n"+  dTSTART +
    	  "\r\n"+  dTEND +
    	  "\r\n"+  recurring +
    	  "\r\n"+  classification_end +
    	  "\r\n"+  "END:VCALENDAR" +
    	  "\r\n");
      
      fw.close();
      
      System.out.println("Done.\n");
      
      System.out.println("BEGIN:VCALENDAR" +
        	  "\r\n"+  version +
        	  "\r\n"+  timeZone +
        	  "\r\n"+  classification +
        	  "\r\n"+  comment +
        	  "\r\n"+  location +
        	  "\r\n"+  resources +
        	  "\r\n"+  dTSTART +
        	  "\r\n"+  dTEND +
        	  "\r\n"+  recurring +
        	  "\r\n"+  classification_end +
        	  "\r\n"+  "END:VCALENDAR" +
        	  "\r\n");
    } catch (IOException e) {
      System.err.println("An error occurred when opening the file. Aborting.");
      return;
    }
    }

    /*
    * Block of get methods used for testing
    */
    public String getVersion() {
    return version;
    }

    public String getClassification() {
    return classification;
    }

    public String getClassificationEnd() {
    return classification_end;
    }

    public String getComment() {
    return comment;
    }

    public String getLocation() {
    return location;
    }

    public String getResources() {
    return resources;
    }

    public String getDTSTART() {
    return dTSTART;
    }

    public String getDTEND() {
    return dTEND;
    }

    public String getTimeZone() {
    return timeZone;
    }

    public String getRecurring() {
    return recurring;
    }
}
